<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>修改</title>
    <link rel="stylesheet" href="${ctx}/static/js/layui/css/layui.css">
    <link rel="stylesheet" href="${ctx}/static/js/formSelects-v4.css"/>
    <style type="text/css">
        .msg {
            color: red !important;
        }
    </style>
</head>
<body>
<div style="padding: 10px;">
    <form class="layui-form" action="">
        <input type="hidden" name="id" value="${orders.id}">


        <div class="layui-form-item">
            <label class="layui-form-label">备注</label>
            <div class="layui-input-inline">
                <input type="text" name="remark" autocomplete="off" class="layui-input" value="${orders.remark}"/>
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
    <script src="${ctx}/static/js/layui/layui.js"></script>
    <script>
        //Demo
        layui.config({
            base: '${ctx}/static/js/' //此处路径请自行处理, 可以使用绝对路径
        }).extend({
            formSelects: 'formSelects-v4.min'
        });
        layui.use(['form', 'upload', 'formSelects'], function () {
            var form = layui.form;
            var upload = layui.upload;
            var $ = layui.$;
            var formSelects = layui.formSelects;

            //监听提交
            form.on('submit(formDemo)', function (data) {
                var msg = $(".msg").text();
                msg = msg.trim();
                if (msg != "") {
                    return false;
                }
                //$.post一般来说需要3个参数：url，参数，回调函数
                $.post('${ctx}/orders/update', data.field, function (e) {
                    if (e == "") {
                        parent.layui.table.reload("demo");
                        parent.layer.msg('修改成功', {icon: 1});		//高用父窗口中的layer来提示，这样关闭弹出窗后提示不会立马关闭
                        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                        parent.layer.close(index); //再执行关闭
                    } else {
                        alert("失败");
                    }
                })
                return false;
            });
        });
    </script>
</div>
</body>
</html>